// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.brest.managesambafilesharing;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.Preference;
import android.preference.PreferenceActivity;

/*
 * import android.widget.RadioButton;
 import android.widget.RadioGroup;
 import android.widget.ScrollView;
 import android.widget.TableLayout;
 import android.content.DialogInterface;
 import android.app.AlertDialog;
 * 
 * 
 */
// Referenced classes of package com.funkyfresh.samba:
//            Misc, FileOps, LOG, Dialogs, 
//            SambaInfo, SambaWifiInfo, SambaControl, SetPreference, 
//            WifiWhitelist, SupportLog

public class Preferences extends PreferenceActivity implements
		android.content.SharedPreferences.OnSharedPreferenceChangeListener {
	/*
	 * public Preferences() { alphanumChars =
	 * "01234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	 * extendedOkChars = "!#$%^&()-_{}~"; prefClick = new
	 * android.preference.Preference.OnPreferenceClickListener() {
	 * 
	 * public boolean onPreferenceClick(Preference preference) { if
	 * (!preference.getKey().equals("SharesScreen")) { if
	 * (preference.getKey().equals("appinfo")) handleAppinfoButton(); else if
	 * (preference.getKey().equals("share2")) handleExtraSharedFolders(); else
	 * if (preference.getKey().equals("Uninstall")) handleUninstallButton();
	 * else if (preference.getKey().equals("createsupportlog"))
	 * SupportLog.handleCreatesupportlog(context); else if
	 * (preference.getKey().equals("EditWifiWhiteList"))
	 * WifiWhitelist.handleWifiWhiteListEdit(context); // if(true) goto _L1;
	 * else goto _L3 // _L3: } return true; }
	 * 
	 * final Preferences this$0; { // super(); this$0 = Preferences.this; } }; }
	 * 
	 * private String GetSharableMounts() { String s; String as[]; String s1 =
	 * "";
	 * 
	 * s = Misc.getExternalStorageName(); as = getCandidateMounts(); if (as !=
	 * null && as.length >= 1) {
	 * 
	 * // _L2: int i = 0; do { label0: { if (i < as.length) break label0; s1 =
	 * s; } if (true) continue; StringBuilder stringbuilder = new StringBuilder(
	 * String.valueOf(s)); String s2; if (s.length() > 1) s2 = (new
	 * StringBuilder("|")).append(as[i]).toString(); else s2 = as[i]; s =
	 * stringbuilder.append(s2).toString(); i++; } while (true); } s1 = s;
	 * return s1; }
	 * 
	 * private String GetSharedFolders() { return Misc.getExternalStorageName();
	 * }
	 * 
	 * private String checkKeyForErrors(String s, int i, boolean flag) { String
	 * s1; if (s.length() < 2 || s.length() > i) s1 = (new
	 * StringBuilder("Must be between 2 - ")).append(i)
	 * .append(" characters long.").toString(); else if (!Misc.isValidString( s,
	 * (new StringBuilder(String.valueOf(alphanumChars))).append(
	 * extendedOkChars).toString())) s1 = (new StringBuilder(
	 * "Must only contain letters, numbers, and any of ")).append(
	 * extendedOkChars).toString(); else s1 = null; return s1; }
	 * 
	 * private boolean doesNotSoundDodgy(String s) { boolean flag = false; if (s
	 * != null && s.length() >= 2) { do { String as[]; int i; int j; as = (new
	 * String[] { "secure", "asec", "key" }); i = as.length; j = 0; // _L5: if
	 * (j < i) continue; flag = true; // _L3: if (s.contains(as[j])) break; //
	 * _L4: j++; } while (true); } return flag; }
	 * 
	 * private String[][] getProcMountsAsArray() { String as[] =
	 * FileOps.readFile("/proc/mounts"); String as1[][]; if (as == null ||
	 * as.length < 1) { LOG.e("Unable to open /proc/mounts"); as1 = null; } else
	 * { as1 = new String[6][6];// ) Array.newInstance(java.lang.String, new //
	 * int[] { // as.length, 6 }); int i = 0; while (i < as.length) { if (as[i]
	 * == null) { as1[i][0] = null; } else { String as2[] = as[i].split("\\s",
	 * 6); if (as2 == null || as2.length < 1) { as1[i][0] = null; } else { int j
	 * = 0; while (j < as2.length) { as1[i][j] = as2[j]; j++; } } } i++; } }
	 * return as1; }
	 * 
	 * private void handleAppinfoButton() { Dialogs.d1( context,
	 * "About Samba Filesharing\n\n", (new StringBuilder("Build: "))
	 * .append(Misc.getAppVersionName(context)).append("\n") .append("")
	 * .append(getResources().getString(0x7f07000b))
	 * .append(getResources().getString(0x7f070008))
	 * .append(getResources().getString(0x7f07000a)) .toString(), "OK"); }
	 * 
	 * private void handleExtraSharedFolders() { candidateMounts =
	 * getCandidateMounts(); if (candidateMounts != null &&
	 * candidateMounts.length >= 1) { // goto // _L2; // else // goto // _L1 //
	 * _L1: // Dialogs.d1(context, "Additional Shared Folder", //
	 * "No other read+write FAT based filesystems were detected.", // "Close");
	 * // _L4: // return; // _L2: ScrollView scrollview = new
	 * ScrollView(context); scrollview.setPadding(14, 2, 10, 12); TableLayout
	 * tablelayout = new TableLayout(context); tablelayout.setOrientation(1);
	 * tablelayout.setPadding(5, 5, 5, 5);
	 * tablelayout.setStretchAllColumns(true); tablelayout .setLayoutParams(new
	 * android.view.ViewGroup.LayoutParams( -1, -2)); RadioGroup radiogroup =
	 * new RadioGroup(context); radiogroup.setId(1); int i = 0; do { label0: {
	 * if (i < candidateMounts.length) break label0;
	 * tablelayout.addView(radiogroup); scrollview.addView(tablelayout);
	 * android.app.AlertDialog.Builder builder = new
	 * android.app.AlertDialog.Builder( context);
	 * builder.setTitle("Choose a mount point to share");
	 * builder.setView(scrollview); builder.setPositiveButton( 0x104000a, new
	 * android.content.DialogInterface.OnClickListener() {
	 * 
	 * public void onClick( DialogInterface dialoginterface, int j) { int k =
	 * ((RadioGroup) ((AlertDialog) dialoginterface) .findViewById(1))
	 * .getCheckedRadioButtonId(); if (k > -1 && k < candidateMounts.length)
	 * SetPref.StrPref("share2", candidateMounts[k]); }
	 * 
	 * final Preferences this$0;
	 * 
	 * { this$0 = Preferences.this; // super(); } }); builder.setNegativeButton(
	 * "None", new android.content.DialogInterface.OnClickListener() {
	 * 
	 * public void onClick( DialogInterface dialoginterface, int j) {
	 * SetPref.StrPref("share2", null); }
	 * 
	 * final Preferences this$0;
	 * 
	 * { this$0 = Preferences.this; // super(); } }); builder.create().show(); }
	 * if (true) continue; RadioButton radiobutton = new RadioButton(context);
	 * radiobutton.setId(i); radiobutton.setText(candidateMounts[i]);
	 * radiobutton .setOnClickListener(new android.view.View.OnClickListener() {
	 * 
	 * public void onClick(View view) { RadioGroup radiogroup1; int j;
	 * radiogroup1 = (RadioGroup) view.getParent(); j =
	 * radiogroup1.getChildCount(); if (j < 1) {// goto _L2; else goto _L1 //
	 * _L1: return; // _L2: } else { //
	 * (android.widget.RadioButton)radiogroup1.getChildAt(view.getId()); int k =
	 * 0; do { label0: { if (k < j) break label0; ((RadioButton) radiogroup1
	 * .getChildAt(view.getId())) .setChecked(true); } if (true) continue;
	 * RadioButton radiobutton1 = (RadioButton) radiogroup1 .getChildAt(k); if
	 * (radiobutton1.getId() == view .getId()) radiobutton1.setChecked(true);
	 * else radiobutton1.setChecked(false); k++; } while (true); } // if(true)
	 * goto _L1; else goto _L3 // _L3: } }); radiogroup.addView(radiobutton);
	 * i++; } while (true); } else { Dialogs.d1(context,
	 * "Additional Shared Folder",
	 * "No other read+write FAT based filesystems were detected.", "Close"); }
	 * 
	 * // if(true) goto _L4; else goto _L3 // _L3: }
	 * 
	 * private void handleLocks() { SambaInfo sambainfo = new
	 * SambaInfo(context); SambaWifiInfo sambawifiinfo = new
	 * SambaWifiInfo(context); if (sambainfo.sambaIsEnabled() &&
	 * sambawifiinfo.wifiIsUp()) { boolean flag =
	 * prefs.getBoolean("WifiWakeLock", false); boolean flag1 =
	 * prefs.getBoolean("MulticastEnableLock", false); boolean flag2 =
	 * prefs.getBoolean("NotificationBarIcon", true); if
	 * (sambawifiinfo.managedWifiIsUp()) { if (flag || flag1)
	 * Misc.notificationBarIcon(context, false); Intent intent = new Intent();
	 * intent.setAction("com.funkyfresh.samba.SambaFilesharingService");
	 * intent.putExtra("useWifiLock", flag); intent.putExtra("useMcastLock",
	 * flag1); context.startService(intent); if (!flag && !flag1)
	 * Misc.notificationBarIcon(context, flag2); } else {
	 * Misc.notificationBarIcon(context, flag2); } } }
	 * 
	 * private void handleUninstallButton() { String s =
	 * context.getPackageName(); if (s == null || s.length() < 1) { LOG.e((new
	 * StringBuilder(" bad pkg name = ")).append(s).toString()); Dialogs.d1(
	 * context, "Error",
	 * "There was an error while attempting to call the Android PackageManager.\n\nPlease try manually uninstalling the app. From the 'Home' screen on your device, go to\n\nMenu\n -> Settings\n  -> Applications\n   -> Manage Applications\n\nthen open the entry for Samba Filesharing and press 'Uninstall'.\n"
	 * , "OK"); } else { Intent intent = new Intent();
	 * intent.setAction("com.funkyfresh.samba.STOPSAMBA");
	 * sendBroadcast(intent); Uri uri = Uri.fromParts("package", s, null);
	 * Intent intent1 = new Intent("android.intent.action.VIEW", uri);
	 * LOG.i((new StringBuilder(" Intent.ACTION_VIEW for Uri: ")).append(
	 * uri).toString()); startActivity(intent1); } }
	 * 
	 * private boolean isReadWrite(String s) { boolean flag = true; if (!(s !=
	 * null && s.length() >= 1)) { // goto _L2; else goto _L1 // _L1: flag =
	 * false; // _L4: return flag; } else { // _L2: do { String as[]; int i; int
	 * j; as = s.split(","); i = as.length; j = 0; // _L6: label0: { if (j < i)
	 * break label0; flag = false; } // if(true) goto _L4; else goto _L3 // _L3:
	 * String s1 = as[j]; if (s1 != null && s1.length() > 1 &&
	 * s1.equalsIgnoreCase("rw")) { // goto // _L4; // else // goto // _L5 flag
	 * = true; return flag; } // _L5: j++; } while (true); } }
	 * 
	 * 
	 * private boolean isValidFsType(String s) { boolean flag; String as[]; flag
	 * = true; as = new String[flag]; as[0] = "vfat"; if(s != null && s.length()
	 * >= flag) goto _L2; else goto _L1 _L1: flag = false; _L4: return flag;
	 * _L2: int i; int j; i = as.length; j = 0; _L6: if(j < i) continue; flag =
	 * false; if(true) goto _L4; else goto _L3 _L3:
	 * if(s.equalsIgnoreCase(as[j])) goto _L4; else goto _L5 _L5: j++; goto _L6
	 * }
	 * 
	 * private void newConfigSet() { if (!SmbCtl.rebuildSmbConfig()) {
	 * LOG.e(" Error rebuilding samba config file. Check logcat for details");
	 * Dialogs.d1( context, "Reconfiguration Error",
	 * "There was an error updating the password file - please check logcat",
	 * "OK"); } else { requiresAppRestart = true; } }
	 * 
	 * private void newPasswdSet() { if (!SmbCtl.rebuildSmbPasswd()) {
	 * FileOps.rmFile((new StringBuilder(String.valueOf(BASEDIR))).append(
	 * "smbpasswd").toString()); LOG.e((new StringBuilder(" Error changing '"))
	 * .append(SmbCtl.getUserName())
	 * .append("' user password. Check logcat for details") .toString());
	 * Dialogs.d1( context, "Error changing password",
	 * "There was an error updating the password file - please check logcat",
	 * "OK"); } else { requiresAppRestart = false; } }
	 * 
	 * private void newUsernameSet() { if (!SmbInf.passwdNotSet() &&
	 * !SmbCtl.rebuildSmbPasswd()) { FileOps.rmFile((new
	 * StringBuilder(String.valueOf(BASEDIR))).append( "smbpasswd").toString());
	 * LOG.e((new StringBuilder(" Error setting '"))
	 * .append(SmbCtl.getUserName())
	 * .append("' password. Check logcat for details").toString()); Dialogs.d1(
	 * context, "Error setting password",
	 * "There was an error updating the password file for the new username- please check logcat"
	 * , "OK"); } }
	 * 
	 * private void newWakeLockSetting(boolean flag) { LOG.e((new
	 * StringBuilder("WakeLock Pref, key = ")).append(flag) .toString()); }
	 * 
	 * public String arrayToString(String as[]) { String s; if (as == null ||
	 * as.length < 1) { s = ""; } else { s = ""; int i = 0; while (i <
	 * as.length) { s = (new StringBuilder(String.valueOf(s))).append(" ")
	 * .append(as[i]).toString(); i++; } } return s; }
	 * 
	 * public String[] getCandidateMounts() { String s; String as[][]; s = "";
	 * as = getProcMountsAsArray(); if(as != null && as.length >= 1 && as[0][0]
	 * != null) goto _L2; else goto _L1 _L1: String as1[] = new String[0]; _L4:
	 * return as1; _L2: int i = 0; _L5: label0: { if(i < as.length) break
	 * label0; if(s.equals("")) as1 = new String[0]; else as1 = s.split("\\|");
	 * } if(true) goto _L4; else goto _L3 _L3: if(as[i][0] != null &&
	 * as[i][0].length() > 0 && as[i][1] != null && as[i][1].length() > 2 &&
	 * doesNotSoundDodgy(as[i][1]) &&
	 * !as[i][1].equals(Misc.getExternalStorageName()) &&
	 * isValidFsType(as[i][2]) && isReadWrite(as[i][3])) s = (new
	 * StringBuilder(String
	 * .valueOf(s))).append(as[i][1]).append("|").toString(); i++; goto _L5 }
	 * 
	 * protected void onCreate(Bundle bundle) { super.onCreate(bundle); context
	 * = this; SmbInf = new SambaInfo(context); SetPref = new
	 * SetPreference(context); SmbCtl = new SambaControl(context);
	 * addPreferencesFromResource(0x7f040000); prefs =
	 * PreferenceManager.getDefaultSharedPreferences(context); BUILD =
	 * Misc.getAppVersionName(context); BASEDIR =
	 * "/data/data/com.funkyfresh.samba/files/"; aboutPref =
	 * findPreference("appinfo");
	 * aboutPref.setOnPreferenceClickListener(prefClick); createLogPref =
	 * findPreference("createsupportlog");
	 * createLogPref.setOnPreferenceClickListener(prefClick); uninstallPref =
	 * findPreference("Uninstall");
	 * uninstallPref.setOnPreferenceClickListener(prefClick); addsharedfolder =
	 * findPreference("share2");
	 * addsharedfolder.setOnPreferenceClickListener(prefClick);
	 * EditWifiWhiteList = findPreference("EditWifiWhiteList");
	 * EditWifiWhiteList.setOnPreferenceClickListener(prefClick); }
	 * 
	 * protected void onDestroy() { LOG.i(" Entered"); super.onDestroy(); }
	 * 
	 * protected void onPause() { LOG.i(" Entered"); super.onPause();
	 * getPreferenceScreen().getSharedPreferences()
	 * .unregisterOnSharedPreferenceChangeListener(this); }
	 * 
	 * protected void onResume() { super.onResume();
	 * getPreferenceScreen().getSharedPreferences()
	 * .registerOnSharedPreferenceChangeListener(this); }
	 * 
	 * public void onSharedPreferenceChanged(SharedPreferences
	 * sharedpreferences, String s) { new SambaWifiInfo(context);
	 * requiresAppRestart = false; if(!s.equals("EnableNotification") &&
	 * !s.equals("Orientation") && !s.equals("smbconfdnd") &&
	 * !s.equals("localmasterno") && !s.equals("share2") &&
	 * !s.equals("DispEnableDisablePopups") && !s.equals("UnixExtensions") &&
	 * !s.equals("ignorewifistate")) goto _L2; else goto _L1 _L1: return; _L2:
	 * if(s.equals("WifiWhitelistEnabled") ||
	 * s.equals("WhiteListAllowManualStart"))
	 * WifiWhitelist.handleWhiteListChanges(context); else
	 * if(s.equals("ScreenWakeLock") || s.equals("MulticastEnableLock") ||
	 * s.equals("WifiWakeLock")) {
	 * newWakeLockSetting(sharedpreferences.getBoolean(s, false));
	 * if(sharedpreferences.getBoolean(s, false) &&
	 * sharedpreferences.getBoolean("DispEnableDisablePopups", false))
	 * Dialogs.d1(context, "A note about Wakelock",
	 * "Enabling WakeLock maintains WiFi network performance by preventing your Android device from entering sleep mode while the Samba Filesharing app is the active app on the screen.\n\nYour battery charge will run down faster than normal, so keep an eye on the battery juice levels."
	 * , "OK"); if(!s.equals("ScreenWakeLock")) handleLocks(); } else { String
	 * s1; if(s.equals("username") || s.equals("password")) s1 =
	 * checkKeyForErrors(sharedpreferences.getString(s, ""), 14, false); else s1
	 * = checkKeyForErrors(sharedpreferences.getString(s, ""), 15, true); if(s1
	 * == null) { if(s.equals("password")) newPasswdSet();
	 * if(s.equals("username")) newUsernameSet(); if(s.equals("workgroup") ||
	 * s.equals("netbiosname")) newConfigSet(); if(requiresAppRestart)
	 * Dialogs.d1(context, "Preference saved",
	 * "Disable then Enable Samba to activate the new settings.\n\nYou may need to clear the cached credentials on the client before you can reconnect: see \n\n    net use /delete\n\n from Windows 'cmd.exe'."
	 * , "OK"); } else { String s2 = (new
	 * StringBuilder(String.valueOf(s))).append(": ").append(s1).toString();
	 * android.content.SharedPreferences.Editor editor =
	 * sharedpreferences.edit(); context = this; Dialogs.d1(context, "ERROR",
	 * s2, "OK"); getPreferenceScreen().getSharedPreferences().
	 * unregisterOnSharedPreferenceChangeListener(this); editor.putString(s,
	 * getString(getResources().getIdentifier((new
	 * StringBuilder(String.valueOf(s))).append("Default").toString(), "string",
	 * "com.funkyfresh.samba"))); editor.commit();
	 * getPreferenceScreen().getSharedPreferences
	 * ().registerOnSharedPreferenceChangeListener(this); } } if(true) goto _L1;
	 * else goto _L3 _L3: }
	 */

	public void onSharedPreferenceChanged(SharedPreferences sharedpreferences,
			String s) {

	}

	public static final String INTENT_NEWPASSWD = "com.funkyfresh.samba.NEWPASSWD";
	public static final String INTENT_RECONFIGSAMBA = "com.funkyfresh.samba.RECONFIGURED";
	public static final String INTENT_RESTARTSAMBA = "com.funkyfresh.samba.RESTARTSAMBA";
	public static final String INTENT_STOPSAMBA = "com.funkyfresh.samba.STOPSAMBA";
	private String BASEDIR;
	private String BUILD;
	private Preference EditWifiWhiteList;
	private SetPreference SetPref;
	private Preference SharesScreen;
	private SambaControl SmbCtl;
	private SambaInfo SmbInf;
	private Preference aboutPref;
	private Preference addsharedfolder;
	private String alphanumChars;
	private String candidateMounts[];
	private Context context;
	private Preference createLogPref;
	private String extendedOkChars;
	public android.preference.Preference.OnPreferenceClickListener prefClick;
	private SharedPreferences prefs;
	private boolean requiresAppRestart;
	private Preference uninstallPref;

}
